#pragma config(Sensor, dgtl1,  btn1,           sensorTouch)
#pragma config(Sensor, dgtl2,  btn2,           sensorTouch)
#pragma config(Motor,  port1,           armMotor,      tmotorVex393HighSpeed, openLoop)
#pragma config(Motor,  port2,           frontLeft,     tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor,  port3,           frontRight,    tmotorServoContinuousRotation, openLoop)
#pragma config(Motor,  port4,           backLeft,      tmotorVex269, openLoop, reversed, encoder, encoderPort, None, 1000)
#pragma config(Motor,  port5,           backRight,     tmotorServoContinuousRotation, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)

#include "Vex_Competition_Includes.c"   //Main competition background code...do not modify!

/////////////////////////////////////////////////////////////////////////////////////////
//
//                          Pre-Autonomous Functions
//
// You may want to perform some actions before the competition starts. Do them in the
// following function.
//
/////////////////////////////////////////////////////////////////////////////////////////

void pre_auton()
{
	// Set bStopTasksBetweenModes to false if you want to keep user created tasks running between
	// Autonomous and Tele-Op modes. You will need to manage all user created tasks if set to false.
	bStopTasksBetweenModes = true;

	// All activities that occur before the competition starts
	// Example: clearing encoders, setting servo positions, ...
}

/////////////////////////////////////////////////////////////////////////////////////////
//
//                                 Autonomous Task
//
// This task is used to control your robot during the autonomous phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////

task autonomous()
{
	while (true){
		if(btn1==false && btn2==false){
			wait1Msec(1000);
			motor[frontLeft] = 127;
			motor[frontRight] = 127;
			motor[backLeft] = 127;
			motor[backRight] = 127;
		}
		else{
			motor[frontLeft] = 0;
			motor[frontRight] = 0;
			motor[backLeft] = 0;
			motor[backRight] = 0;
			wait1Msec(5000);
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////////
//
//                                 User Control Task
//
// This task is used to control your robot during the user control phase of a VEX Competition.
// You must modify the code to add your own robot specific commands here.
//
/////////////////////////////////////////////////////////////////////////////////////////

task usercontrol()
{
	// User control code here, inside the loop

	while (true)
	{
		//Set motor direction based on button
		if(btn1==false && btn2==false){
			//Tank Drive
			motor[frontLeft] = vexRT[Ch3];
			motor[frontRight] = vexRT[Ch2];
			motor[backLeft] = vexRT[Ch3];
			motor[backRight] = vexRT[Ch2];
		}
		else{
			motor[frontLeft] = -127;
			motor[frontRight] = -127;
			motor[backLeft] = -127;
			motor[backRight] = -127;
			wait1Msec(2500);
			motor[frontLeft] = 0;
			motor[frontRight] = 0;
			motor[backLeft] = 0;
			motor[backRight] = 0;
			wait1Msec(500);
		}
	}
}
